package com.test.datasource;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

@Configuration
@EnableTransactionManagement
public class DataSourceDefine {

    public static final String DATASOURCE_PARK = "parkDataSource";
    public static  final String DATASOURCE_UNIANCE = "unianceDataSource";

    @Bean(name = DATASOURCE_PARK)
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.druid.park")
    public DataSource userDataSource0() {
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * 联通活动  promotion 数据源
     */
    @Bean(name = DATASOURCE_UNIANCE)
    @ConfigurationProperties(prefix = "spring.datasource.druid.promotion")
    public DataSource unianceDataSource() {
        return DruidDataSourceBuilder.create().build();
    }

}
